#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	char s[110];
	while(scanf("%s",&s)!=EOF)
	{
		int flag = 0;
		int len = strlen(s);
		for(int i = 1;i<len;i++)
		{
			if(s[i]>='a'&&s[i]<='z')
			{
				flag = 1;
				break;
			}
		}
		if(!flag)
		{
			if(s[0]>='a'&&s[0]<='z') s[0] = s[0]-32;
			else s[0] = s[0]+32;
			for(int i = 1;i<len;i++) s[i] = s[i]+32;
		}
		puts(s);
	}
}
